package com.blog;

import java.util.HashMap;
import java.util.Map;

/**
 * 90%的同学都没搞清楚的 Java 字符串常量池问题（图文并茂）
 * https://my.oschina.net/u/4519772/blog/4255335
 * @author xiaoming
 * @date 2020-05-17 19:04
 */
public class StringContentPool {

    public static void main(String[] args) {
        String a = "aaa";
        String b = new String("aaa");
        // native
        a.intern();

        System.out.println(a == b);

        System.out.println(a.equals(b));

        System.out.println("o----");
        Map<String, Object> map = new HashMap<>();
        map.put("a", 0);
//      System.out.println(map.get("a") instanceof Integer);

        if (map.get("a") == "0") {
            System.out.println( "0" + true);
        }

        if (0 == (int)map.get("a")) {
            System.out.println(true);
        } else {
            System.out.println(false);
        }

    }
}
